var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userVo:"",
    amount:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.setData({ amount: options.amount });
    that.onMineInfo();
  },
  //跳转明细页面
  goBalanceDetail:function(){
    wx.navigateTo({
      url: 'balanceDetail',
    })
  },
  //跳转充值页面
  goCz: function () {
    wx.navigateTo({
      url: 'paymentCard',
    })
  },
 
  goGetCash:function(){
    var that = this;
    //var payStatus = that.data.userVo.payStatus;
    //var wxType = that.data.userVo.wxType;
    //var phone = that.data.userVo.telephone;
    if (that.data.bankcardInfoVo == "1") {
      var cardName = that.data.userVo.cardName;
      var cardNum = that.data.userVo.cardNum; 
      wx.showModal({
        title: '提示',
        content: '使用提现功能前，需要完成银行卡认证，校验该银行卡为提现本人持有',
        confirmText: "去认证",
        confirmColor: "#56BDE0",
        success(res) {
          if (res.confirm) {
           // console.log('用户点击确定');
            wx.navigateTo({
              url: 'bindBandCard?cardName=' + cardName + '&cardNum=' + cardNum,
            })
          } else if (res.cancel) {
            //console.log('用户点击取消')
          }
        }
      });
    } else {
      //var bankCardName = that.data.bankcardInfoVo.bankCardName;
      //var bankCardNumber = that.data.bankcardInfoVo.bankCardNumber;
      wx.navigateTo({
      //  url: 'getCash?amount=' + that.data.amount + '&bankCardName=' + bankCardName + '&bankCardNumber=' + bankCardNumber + '&payStatus=' + payStatus + '&wxType=' + wxType + '&phone=' + phone,
        url: 'getCash?amount=' + that.data.amount,
      })
    }
  },

  onMineInfo: function () {
    var that = this;
    wx.request({
      method: "POST",
      url: 'https://www.zaishengwang.com/wx/toHomeUser.do',
      dataType: 'json',
      header: {
        'content-type': 'application/x-www-form-urlencoded',
      },
      data: {
        id: app.globalData.userId,
      },
      success: function (res) {
      //  console.log(res.data);
      //  console.log(res.data.bankcardInfoVo);
        that.setData({
          userVo: res.data.userVo,
          bankcardInfoVo: res.data.bankcardInfoVo
        });
      },
      fail: function (error) {
        console.log(error);
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    wx.request({
      method: "POST",
      url: 'https://www.zaishengwang.com/wx/serchUserAccount.do',
      dataType: 'json',
      header: {
        'content-type': 'application/x-www-form-urlencoded',
      },
      data: {
        bId: app.globalData.userId
      },
      success: function (res) {
        var amount = res.data.accountVo.amount;
        that.setData({ amount: amount });
      },
      fail: function (error) {
        console.log(error);
      }

    })
  },

  //goQuestion
  goQuestion: function () {
    wx.navigateTo({
      url: 'question',
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})